home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mquery / msort.frm < prev    next >
Text File  |  1995-05-02  |  3KB  |  131 lines

  1. VERSION 2.00
  2. Begin Form fSort 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Sort Records"
  6.    ClientHeight    =   2370
  7.    ClientLeft      =   3090
  8.    ClientTop       =   3120
  9.    ClientWidth     =   5070
  10.    ControlBox      =   0   'False
  11.    Height          =   2775
  12.    Left            =   3030
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2412
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   5160
  19.    Top             =   2775
  20.    Width           =   5190
  21.    Begin ListBox cFieldList 
  22.       BackColor       =   &H00FFFFFF&
  23.       Height          =   1395
  24.       Left            =   240
  25.       TabIndex        =   1
  26.       Tag             =   " OL"
  27.       Top             =   360
  28.       Width           =   1695
  29.    End
  30.    Begin CommandButton OkayButton 
  31.       Caption         =   "&OK"
  32.       Default         =   -1  'True
  33.       Enabled         =   0   'False
  34.       Height          =   372
  35.       Left            =   2340
  36.       TabIndex        =   3
  37.       Top             =   420
  38.       Width           =   1691
  39.    End
  40.    Begin CommandButton CancelButton 
  41.       Cancel          =   -1  'True
  42.       Caption         =   "&Cancel"
  43.       Height          =   372
  44.       Left            =   2340
  45.       TabIndex        =   0
  46.       Top             =   1320
  47.       Width           =   1691
  48.    End
  49.    Begin Label FieldListLabel 
  50.       BackColor       =   &H00C0C0C0&
  51.       Caption         =   "Fields:"
  52.       Height          =   192
  53.       Left            =   240
  54.       TabIndex        =   2
  55.       Top             =   120
  56.       Width           =   1092
  57.    End
  58. End
  59. Option Explicit
  60. Dim FNotFound As Integer
  61.  
  62. Sub OkayButton_Click ()
  63.    Dim i As Integer
  64.    Dim k As Integer
  65.    Dim stripedSort As String
  66.    On Error GoTo FindErr
  67.  
  68.   
  69.    FNotFound = False
  70.    SetHourGlass Me
  71.     gSortStr = cFieldList
  72.     stripedSort = gSortStr ' needed for compare later
  73.  
  74.     gSortStr = "[" + gSortStr + "]"
  75.       
  76.  
  77. ' see if this was not a stored query..if not add to SQL statement for save
  78.  If Not gStoredFlag Then
  79.     i = InStr(1, UCase(gstDynaString), "ORDER BY") 'see if a where exists
  80.         If i = 0 Then
  81.             gstDynaString = Trim(gstDynaString) & " Order By " & gTblname & "." & gSortStr
  82.         Else
  83.             k = InStr(i + 8, UCase(gstDynaString), UCase(stripedSort))' is this sort already used?
  84.             If k = 0 Then
  85.                 gstDynaString = Trim(gstDynaString) & "," & gTblname & "." & gSortStr
  86.             End If
  87.         End If
  88.  End If
  89.    
  90.    Hide
  91.    GoTo FindEnd
  92.  
  93. FindErr:
  94.    If Err <> EOF_ERR Then
  95.      ShowError
  96.      Resume FindEnd
  97.    Else
  98.      FNotFound = True
  99.      Resume Next
  100.    End If
  101.  
  102. FindEnd:
  103.    ResetMouse Me
  104.  
  105. End Sub
  106.  
  107. Sub CancelButton_Click ()
  108.   Hide
  109.   'set the flag for the dynaset/dynagrid form
  110.   gfFindFailed = True
  111. End Sub
  112.  
  113. Sub cFieldList_Click ()
  114.   If cFieldList <> "" Then
  115.     OkayButton.Enabled = True
  116.   Else
  117.     OkayButton.Enabled = False
  118.   End If
  119. End Sub
  120.  
  121. Sub Form_Load ()
  122.    Me.Left = (screen.Width - Me.Width) / 2
  123.    Me.Top = (screen.Height - Me.Height) / 2
  124.  
  125. End Sub
  126.  
  127. Sub Form_Paint ()
  128.   Outlines Me
  129. End Sub
  130.  
  131.